<?php


if (isset($_POST)) {
	if ($post_id = $path[4] and ctype_digit($post_id)) {
		$category_id = $db->fetchOne("SELECT category_id FROM blog_posts WHERE id=? AND site_id=?", array($post_id, $site['id']));

		$db->delete('blog_posts', array($db->quoteInto("id=?", $post_id), $db->quoteInto("site_id=?", $site['id'])));
		
		if (!(isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') and isset($_SERVER['HTTP_REFERER'])) {
			header("Location: /admin/blog/posts/?id={$category_id}");
		}
	}
}

